﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Data;
using System.Web.UI.WebControls;
using Pos.DAL;
using Pos.Model;
using Pos.SharedLibrary;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

namespace POS
{
    public partial class DineIn : System.Web.UI.Page
    {
        public string DataCategory = "[]",teststring = "test";

        public string[][] category;
        public string[][] dish;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DishCategoryDAL categoryDAL = new DishCategoryDAL();
                DataTable dt = categoryDAL.GetAll();
                JArray array = new JArray();
                JArray obj = new JArray();
                obj.Add("EnglishName");
                obj.Add("CategoryID");
                array.Add(obj);

                if (dt != null)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        obj = new JArray();
                        obj.Add( dt.Rows[i]["EnglishName"].ToString());
                        obj.Add( dt.Rows[i]["CategoryID"].ToString());
                        array.Add(obj);
                    }
                    DataCategory = array.ToString();
                }
                //DataCategory = "123543";
            }

        }

        protected void btn_Category1_Click(object sender, EventArgs e)
        {
            string CategoryID = rightbuttonhf1.Value;
            DishDAL dishDAL = new DishDAL();
            DataTable dt = dishDAL.GetAllByCategory(CategoryID);
            if (dt != null)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    dish[i][0] = dt.Rows[i]["EnglishName"].ToString();
                    dish[i][1] = dt.Rows[i]["DishID"].ToString();
                }
            }
        }
    }
}